package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.mcsappframework.utils.DateUtil;
import com.meichis.yndms.model.EventNotification;
import com.meichis.yndms.repository.manager.EventNotificationManager;

import java.util.List;

public class EventNotificationVm extends MyViewModel {

    private MutableLiveData<String> BeginTime;
    private MutableLiveData<String> EndTime;

    private MutableLiveData<List<EventNotification>> eventData;

    public MutableLiveData<List<EventNotification>> getEventData() {
        if (eventData == null) {
            eventData = new MutableLiveData<>();
        }
        return eventData;
    }

    public MutableLiveData<String> getBeginTime() {
        if (BeginTime == null) {
            BeginTime = new MutableLiveData<>();
            BeginTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), -7));
        }

        return BeginTime;
    }

    public MutableLiveData<String> getEndTime() {
        if (EndTime == null) {
            EndTime = new MutableLiveData<>();
            EndTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), 7));
        }
        return EndTime;
    }

    public void getTpmAppSummary() {
        EventNotificationManager.getInstance().getTpmAppSummary(getShowDialog(), getUserInfo().getValue().getOrgId(), getEventData());
    }
}
